﻿using SaaS.Model.Enums;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using XCore.Domain.Entities;
using XCore.Extensions;

namespace SaaS.Model.Entity.Gateways
{
    /// <summary>
    /// 门户基础表
    /// </summary>
    [Table("Gate_Basics")]
    public class Basics : Entity<int>, IHasCreateionIpAddress, IHasCreationTime
    {
        public int? TenantId { get; set; }
        /// <summary>
        /// 标题
        /// </summary>
        [Required]
        [StringLength(128)]
        public string Title { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public BasicsType Type { get; set; }
        /// <summary>
        /// 状态
        /// </summary>
        public ArticleStatus Status { get; set; }
        /// <summary>
        /// 图片，支持多图，以,号分隔
        /// </summary>
        public string Images { get; set; }
        /// <summary>
        /// 发布时间，可定时发布
        /// </summary>
        public DateTime? ReleaseTime { get; set; }
        /// <summary>
        /// 排序
        /// </summary>
        public short Sort { get; set; }
        /// <summary>
        /// 标签
        /// </summary>
        public short Tag { get; set; }
        /// <summary>
        /// 配置信息 Query格式字符串
        /// </summary>
        public string SettingString { get; set; }

        /// <summary>
        /// 配置信息
        /// </summary>
        private BasicsSetting _basicsSetting;
        [NotMapped]
        public BasicsSetting BasicsSetting
        {
            get
            {
                if (_basicsSetting == null) _basicsSetting = new BasicsSetting(this.SettingString);
                return _basicsSetting;
            }
            set
            {
                _basicsSetting = value;
            }
        }

        public int? CreatorUserId { get; set; }
        public DateTime CreationTime { get; set; }
        public int? LastModifyUserId { get; set; }
        public DateTime? LastModifyDate { get; set; }
        public int? DeleteUserId { get; set; }
        public bool IsDeleted { get; set; }
        public DateTime? DeleteTime { get; set; }
        public string IP { get; set; }
    }
}
